<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <title>直播间</title>
  <link rel="stylesheet" type="text/css" href="../css/api.css" />
  <link rel="stylesheet" type="text/css" href="../css/video_live.css" />
</head>

<body>
</body>

</html>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
  var app, core;
  apiready = function () {
    api.setKeepScreenOn({
      keepOn: true
    });
    var session = {
      roomId: api.pageParam.roomId,
      password: api.pageParam.roomPwd,
      nickname: $api.getStorage('uname'),
    }
    core = api.require('gotyeLiveCore');
    core.setDebugLogEnabled({
      enabled: true
    });
    core.authRoomSession(session, function (ret, err) {
      if (ret) {
        // api.alert({
        //   title: 'core.authRoomSession ret', 
        //   msg: JSON.stringify(ret)
        // });
        api.openFrame({
          name: 'video_live_room_frame',
          url: 'video_live_room_frame.html',
          pageParam: api.pageParam,
          rect: {
            x: 0,
            y: 0,
            w: 'auto',
            h: 'auto'
          },
          bounces: false,
          bgColor: 'rgba(0,0,0,0)',
          vScrollBarEnabled: false,
          hScrollBarEnabled: false
        });
      } else {
        // api.alert({
        //   title: 'core.authRoomSession err', 
        //   msg: JSON.stringify(err)
        // });
        api.toast({
          msg: '网络错误，请稍后再试',
          duration: 2000,
          location: 'bottom'
        });
        setTimeout( function () {
          api.closeWin();
        }, 1000);
      }
    });
    api.addEventListener({
      name: 'keyback'
    }, function (ret, err) {
      api.sendEvent({
        name: 'closeRoom',
      });
    });
  }
</script>